From d17547414199f4434289f75ab2b1364cc961982e Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Mon, 8 Jun 2015 14:13:23 +0200 Subject: [PATCH] sched_rt: fix memory leak in rt_init() Introduced by c/s 376bbba "sched_rt: print useful affinity info when dumping". If the allocation of cpumask failed, prv was leaked. Signed-off-by: Andrew Cooper Coverity-ID: 1304398 Reviewed-by: Dario Faggioli --- xen/common/sched_rt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 5836d274b2..4372486b94 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -441,7 +441,7 @@ rt_init(struct scheduler *ops) { _cpumask_scratch = xmalloc_array(cpumask_var_t, nr_cpu_ids); if ( !_cpumask_scratch ) - return -ENOMEM; + goto no_mem; } nr_rt_ops++; @@ -455,6 +455,10 @@ rt_init(struct scheduler *ops) ops->sched_data = prv; return 0; + + no_mem: + xfree(prv); + return -ENOMEM; } static void -- 2.30.2